package  io.renren.modules.generator.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.google.common.base.Joiner;
import io.renren.modules.generator.dao.TransitTimeDao;
import io.renren.modules.generator.entity.TransitTimeEntity;
import io.renren.modules.generator.service.TransitTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;


@Service("transitTimeService")
public class TransitTimeServiceImpl extends ServiceImpl<TransitTimeDao, TransitTimeEntity> implements TransitTimeService {

    @Autowired
    private  TransitTimeDao transitTimeDao;

    @Override
    public  List<TransitTimeEntity> queryPage(Map<String, Object> params) {

        return transitTimeDao.queryPage(params);
    }
    @Override
    public  int queryPageTotal(Map<String, Object> params) {

        return transitTimeDao.queryPageTotal(params);
    }

    @Override
    public TransitTimeEntity queryTimeByFromDtAreaIdsAndToDtAreaIds(List<Integer> fromDtAreaIds, List<Integer> toDtAreaIds) {
        Collections.sort(fromDtAreaIds);
        Collections.sort(toDtAreaIds);
        TransitTimeEntity transitTimeEntity = new TransitTimeEntity();
        transitTimeEntity.setFromCityDtAreaIds(Joiner.on(",").join(fromDtAreaIds));
        transitTimeEntity.setToCityDtAreaIds(Joiner.on(",").join(toDtAreaIds));
        return transitTimeDao.selectOne(transitTimeEntity);
    }


}
